#ifndef _KP_SERVER_H_
#define _KP_SERVER_H_

#include <GLES2/gl2.h>

#include "kp_macro.h"

#include "KPMessage.h"

#include "KPProgram.h"
#include "KPShader.h"
#include "KPTexture.h"

#define MAX_TEXTURES_NUMBER		1024
#define MAX_PROGRAMS_NUMBER		1024
#define MAX_SHADERS_NUMBER		1024

#define MAX_GL_COMMANDS_NUMBER		1024

enum ServerState
{
	IDLE = 0,
	PRE_CAPTURE,
	CAPTURING
};

class KPServer
{
public:
	KPServer();
	~KPServer();

	ServerState getState();
	void setState(ServerState state);

	void setClient(int client);

	void clearGLCommandsList();

	//========================================================================================
	void onGL_GenTextures(GLsizei n, GLuint* textures);
	void onGL_DeleteTextures(GLsizei n, const GLuint* textures);
	void onGL_BindTexture (GLenum target, GLuint texture);
	void onGL_DrawArrays(GLenum mode, GLint first, GLsizei count);
	
	void onSwapBuffers();
	//========================================================================================

private:
	volatile ServerState m_state;
	
	KPTexture	m_pTexturesList[MAX_TEXTURES_NUMBER];
	KPProgram	m_pProgramsList[MAX_PROGRAMS_NUMBER];
	KPShader	m_pShadersList[MAX_SHADERS_NUMBER];
	
	KPMessage	m_pGLCommandsList[MAX_GL_COMMANDS_NUMBER];
	int			m_GLCommandsNumber;
	
	int			m_client;
};

#endif
